//
//  SISSHousingProjectInfoView.m
//  SISSAPP
//
//  Created by 袁应荣 on 2018/10/17.
//  Copyright © 2018年 优房网. All rights reserved.
//

#import "SISSHousingProjectInfoView.h"
#import "SISSHousesProjectBuildInfoModel.h"

@interface SISSHousingProjectInfoView ()

@property (weak, nonatomic) UILabel *avgPriceTitleLabel;
@property (weak, nonatomic) UILabel *avgPriceLabel;
@property (weak, nonatomic) UILabel *realEstateDeveloperTitleLabel;
@property (weak, nonatomic) UILabel *realEstateDeveloperLabel;
@property (weak, nonatomic) UILabel *projectOpeningDateTitleLabel;
@property (weak, nonatomic) UILabel *projectOpeningDateLabel;
@property (weak, nonatomic) UILabel *moveInDateTitleLabel;
@property (weak, nonatomic) UILabel *moveInDateLabel;
@property (weak, nonatomic) UILabel *floorAreaTitleLabel;
@property (weak, nonatomic) UILabel *floorAreaLabel;
@property (weak, nonatomic) UILabel *decorationTitleLabel;
@property (weak, nonatomic) UILabel *decorationLabel;
@property (weak, nonatomic) UILabel *coverAreaTitleLabel;
@property (weak, nonatomic) UILabel *coverAreaLabel;
@property (weak, nonatomic) UILabel *panelnameTitleLabel;
@property (weak, nonatomic) UILabel *panelnameLabel;
//@property (weak, nonatomic) UILabel *plotRatioTitleLabel;
//@property (weak, nonatomic) UILabel *plotRatioLabel;
@property (weak, nonatomic) UILabel *greenRateTitleLabel;
@property (weak, nonatomic) UILabel *greenRateLabel;
//@property (weak, nonatomic) UILabel *buildingTypeTitleLabel;
//@property (weak, nonatomic) UILabel *buildingTypeLabel;
//@property (weak, nonatomic) UILabel *propertyTypeTitleLabel;
//@property (weak, nonatomic) UILabel *propertyTypeLabel;

@end
@implementation SISSHousingProjectInfoView

- (void)setBuildInfoModel:(SISSHousesProjectBuildInfoModel *)buildInfoModel {
    _buildInfoModel = buildInfoModel;
    
    NSString *unitStr = [buildInfoModel.priceRange isEqualToString:@"未定价"] ? @"" : @"元/㎡";
    self.avgPriceLabel.text = [NSString stringWithFormat:@"%@%@",buildInfoModel.priceRange,unitStr];
    self.realEstateDeveloperLabel.text = buildInfoModel.explCom;
    self.projectOpeningDateLabel.text = buildInfoModel.makeDate;
    self.moveInDateLabel.text = buildInfoModel.rzDate;
    self.decorationLabel.text = buildInfoModel.decoration;
    self.floorAreaLabel.text = buildInfoModel.buildSqar;
    self.panelnameLabel.text = [NSString stringWithFormat:@"%@%@",buildInfoModel.town,buildInfoModel.block]; // 所属商区
//    self.plotRatioLabel.text = @"";
    self.coverAreaLabel.text = buildInfoModel.landSqar;
    self.greenRateLabel.text = buildInfoModel.greenRate;
//    self.buildingTypeLabel.text = buildInfoModel.btype;
//    self.propertyTypeLabel.text = buildInfoModel.htype;
}

- (void)initUI {
    [super initUI];
    
    UILabel *avgPriceTitleLabel = [UILabel yyr_labelWithText:@"均价：" fontSize:21 textColor:MAIN_TEXT_COLOR];
    [self addSubview:avgPriceTitleLabel];
    self.avgPriceTitleLabel = avgPriceTitleLabel;
    
    UILabel *avgPriceLabel = [UILabel yyr_labelWithText:@"--元/㎡" fontSize:21 textColor:MAIN_TEXT_COLOR];
    [self addSubview:avgPriceLabel];
    self.avgPriceLabel = avgPriceLabel;
    
    
    UILabel *realEstateDeveloperTitleLabel = [UILabel yyr_labelWithText:@"开发商：" fontSize:15 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:realEstateDeveloperTitleLabel];
    self.realEstateDeveloperTitleLabel = realEstateDeveloperTitleLabel;
    
    UILabel *realEstateDeveloperLabel = [UILabel yyr_labelWithText:@"--" fontSize:15 textColor:MAIN_TEXT_COLOR ];
    [self addSubview:realEstateDeveloperLabel];
    self.realEstateDeveloperLabel = realEstateDeveloperLabel;
    
    UILabel *projectOpeningDateTitleLabel = [UILabel yyr_labelWithText:@"开盘时间：" fontSize:15 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:projectOpeningDateTitleLabel];
    self.projectOpeningDateTitleLabel = projectOpeningDateTitleLabel;
    
    UILabel *projectOpeningDateLabel = [UILabel yyr_labelWithText:@"--" fontSize:15 textColor:MAIN_TEXT_COLOR];
    [self addSubview:projectOpeningDateLabel];
    self.projectOpeningDateLabel = projectOpeningDateLabel;
    
    UILabel *moveInDateTitleLabel = [UILabel yyr_labelWithText:@"入住时间：" fontSize:15 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:moveInDateTitleLabel];
    self.moveInDateTitleLabel = moveInDateTitleLabel;
    
    UILabel *moveInDateLabel = [UILabel yyr_labelWithText:@"--" fontSize:15 textColor:MAIN_TEXT_COLOR];
    [self addSubview:moveInDateLabel];
    self.moveInDateLabel = moveInDateLabel;
    
    UILabel *decorationTitleLabel = [UILabel yyr_labelWithText:@"装修情况：" fontSize:15 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:decorationTitleLabel];
    self.decorationTitleLabel = decorationTitleLabel;
    
    UILabel *decorationLabel = [UILabel yyr_labelWithText:@"--" fontSize:15 textColor:MAIN_TEXT_COLOR];
    [self addSubview:decorationLabel];
    self.decorationLabel = decorationLabel;
    
    UILabel *floorAreaTitleLabel = [UILabel yyr_labelWithText:@"建筑面积：" fontSize:15 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:floorAreaTitleLabel];
    self.floorAreaTitleLabel = floorAreaTitleLabel;
    
    UILabel *floorAreaLabel = [UILabel yyr_labelWithText:@"--㎡" fontSize:15 textColor:MAIN_TEXT_COLOR];
    [self addSubview:floorAreaLabel];
    self.floorAreaLabel = floorAreaLabel;
    
    UILabel *panelnameTitleLabel = [UILabel yyr_labelWithText:@"所属商区：" fontSize:15 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:panelnameTitleLabel];
    self.panelnameTitleLabel = panelnameTitleLabel;
    
    UILabel *panelnameLabel = [UILabel yyr_labelWithText:@"--" fontSize:15 textColor:MAIN_TEXT_COLOR];
    [self addSubview:panelnameLabel];
    self.panelnameLabel = panelnameLabel;
    
    UILabel *coverAreaTitleLabel = [UILabel yyr_labelWithText:@"占地面积：" fontSize:15 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:coverAreaTitleLabel];
    self.coverAreaTitleLabel = coverAreaTitleLabel;
    
    UILabel *coverAreaLabel = [UILabel yyr_labelWithText:@"--" fontSize:15 textColor:MAIN_TEXT_COLOR];
    [self addSubview:coverAreaLabel];
    self.coverAreaLabel = coverAreaLabel;
    
//    UILabel *plotRatioTitleLabel = [UILabel yyr_labelWithText:@"容积率：" fontSize:15 textColor:SECONDARY_TEXT_COLOR];
//    [self addSubview:plotRatioTitleLabel];
//    self.plotRatioTitleLabel = plotRatioTitleLabel;
//
//    UILabel *plotRatioLabel = [UILabel yyr_labelWithText:@"4" fontSize:15 textColor:MAIN_TEXT_COLOR];
//    [self addSubview:plotRatioLabel];
//    self.plotRatioLabel = plotRatioLabel;
    
    UILabel *greenRateTitleLabel = [UILabel yyr_labelWithText:@"绿化率：" fontSize:15 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:greenRateTitleLabel];
    self.greenRateTitleLabel = greenRateTitleLabel;
    
    UILabel *greenRateLabel = [UILabel yyr_labelWithText:@"--" fontSize:15 textColor:MAIN_TEXT_COLOR];
    [self addSubview:greenRateLabel];
    self.greenRateLabel = greenRateLabel;
    
    
//    UILabel *buildingTypeTitleLabel = [UILabel yyr_labelWithText:@"建筑类型：" fontSize:15 textColor:SECONDARY_TEXT_COLOR];
//    [self addSubview:buildingTypeTitleLabel];
//    self.buildingTypeTitleLabel = buildingTypeTitleLabel;
//
//    UILabel *buildingTypeLabel = [UILabel yyr_labelWithText:@"高层,洋房" fontSize:15 textColor:MAIN_TEXT_COLOR];
//    [self addSubview:buildingTypeLabel];
//    self.buildingTypeLabel = buildingTypeLabel;
//
//    UILabel *propertyTypeTitleLabel = [UILabel yyr_labelWithText:@"物业类型：" fontSize:15 textColor:SECONDARY_TEXT_COLOR];
//    [self addSubview:propertyTypeTitleLabel];
//    self.propertyTypeTitleLabel = propertyTypeTitleLabel;
//
//    UILabel *propertyTypeLabel = [UILabel yyr_labelWithText:@"{物业类型}" fontSize:15 textColor:MAIN_TEXT_COLOR];
//    [self addSubview:propertyTypeLabel];
//    self.propertyTypeLabel = propertyTypeLabel;
    
}

- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGFloat margin = 8.0;
    
    [self.avgPriceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf).offset(2 * margin);
        make.left.equalTo(weakSelf).offset(2 * margin);
    }];
    
    [self.avgPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.avgPriceTitleLabel);
        make.left.equalTo(weakSelf.avgPriceTitleLabel.mas_right).offset(0.5 * margin);
    }];
    
    [self.realEstateDeveloperTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.avgPriceTitleLabel.mas_bottom).offset(2 * margin);
        make.left.equalTo(weakSelf.avgPriceTitleLabel);
    }];
    
    [self.realEstateDeveloperLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.realEstateDeveloperTitleLabel);
        make.left.equalTo(weakSelf.realEstateDeveloperTitleLabel.mas_right).offset(0.5 * margin);
    }];
    
    [self.projectOpeningDateTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.realEstateDeveloperTitleLabel.mas_bottom).offset(2 * margin);
        make.left.equalTo(weakSelf.realEstateDeveloperTitleLabel);
    }];
    
    [self.projectOpeningDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.projectOpeningDateTitleLabel);
        make.left.equalTo(weakSelf.projectOpeningDateTitleLabel.mas_right).offset(0.5 * margin);
    }];
    
    [self.moveInDateTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.projectOpeningDateTitleLabel);
        make.left.equalTo(weakSelf.mas_centerX);
    }];
    
    [self.moveInDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.moveInDateTitleLabel);
        make.left.equalTo(weakSelf.moveInDateTitleLabel.mas_right).offset(0.5 * margin);
    }];
    
    [self.floorAreaTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.projectOpeningDateTitleLabel.mas_bottom).offset(2 * margin);
        make.left.equalTo(weakSelf.projectOpeningDateTitleLabel);
    }];
    
    [self.floorAreaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.floorAreaTitleLabel);
        make.left.equalTo(weakSelf.floorAreaTitleLabel.mas_right).offset(0.5 * margin);
    }];
    
    [self.decorationTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.floorAreaTitleLabel);
        make.left.equalTo(weakSelf.mas_centerX);
    }];
    
    [self.decorationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.decorationTitleLabel);
        make.left.equalTo(weakSelf.decorationTitleLabel.mas_right).offset(0.5 * margin);
    }];
    
    [self.coverAreaTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.floorAreaTitleLabel.mas_bottom).offset(2 * margin);
        make.left.equalTo(weakSelf.floorAreaTitleLabel);
    }];
    
    [self.coverAreaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.coverAreaTitleLabel);
        make.left.equalTo(weakSelf.coverAreaTitleLabel.mas_right).offset(0.5 * margin);
    }];
    
    [self.panelnameTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.coverAreaTitleLabel);
        make.left.equalTo(weakSelf.mas_centerX);
    }];
    
    [self.panelnameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.panelnameTitleLabel);
        make.left.equalTo(weakSelf.panelnameTitleLabel.mas_right).offset(0.5 * margin);
    }];
    
//    [self.plotRatioTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.coverAreaTitleLabel.mas_bottom).offset(2 * margin);
//        make.left.equalTo(weakSelf.coverAreaTitleLabel);
//    }];
//
//    [self.plotRatioLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.plotRatioTitleLabel);
//        make.left.equalTo(weakSelf.plotRatioTitleLabel.mas_right).offset(0.5 * margin);
//    }];
    
//    [self.greenRateTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(weakSelf.plotRatioTitleLabel);
//        make.left.equalTo(weakSelf.mas_centerX);
//    }];
    [self.greenRateTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.coverAreaTitleLabel.mas_bottom).offset(2 * margin);
        make.left.equalTo(weakSelf.coverAreaTitleLabel);
        make.bottom.equalTo(weakSelf).offset(-margin);
    }];

    [self.greenRateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.greenRateTitleLabel);
        make.left.equalTo(weakSelf.greenRateTitleLabel.mas_right).offset(0.5 * margin);
    }];
    
//    [self.buildingTypeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.plotRatioTitleLabel.mas_bottom).offset(2 * margin);
//        make.left.equalTo(weakSelf.plotRatioTitleLabel);
//    }];
//
//    [self.buildingTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.buildingTypeTitleLabel);
//        make.left.equalTo(weakSelf.buildingTypeTitleLabel.mas_right).offset(0.5 * margin);
//    }];
//
//    [self.propertyTypeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.buildingTypeTitleLabel.mas_bottom).offset(2 * margin);
//        make.left.equalTo(weakSelf.buildingTypeTitleLabel);
//        make.bottom.equalTo(weakSelf).offset(-margin);
//    }];
//
//    [self.propertyTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.propertyTypeTitleLabel);
//        make.left.equalTo(weakSelf.propertyTypeTitleLabel.mas_right).offset(0.5 * margin);
//    }];
}

@end
